what the criteria are for a command to be executable?
What I do when I put the commands into the python shell is trial and error. Can Harrison or anybody give a checklist of the preconditions that a command need satisfy before it is executable in python please? For example, [w for w in set(text1) if len(w)>18] is executable but w for w in set(text1) if len(w)>18 and (w for w in set(text1) if len(w)>18) are not.
sorted(wd for wd in set(text1) if len (wd)>15) works, but sorted[wd for wd in set(text1) if len (wd)>15] does not.
The following three all work fine: ['how','are','you'] 'how','are','you' ('how','are','you')
I am confused.
You must be logged in to post. Please login or register an account.
[w for w in set(text1) if len(w)>18] , this is a 1-liner for loop generating a list, which is why it works.
You need the brackets around it to work, which is why the no brackets didn't work, nor did parenthesis (since parenthesis denote a tuple).